home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / dos_win / winsock / maillist / 94-03.Z / 94-03 / text0239.txt < prev    next >
Encoding:
Text File  |  1994-03-30  |  2.1 KB  |  62 lines

  1. >>>>> On Fri, 18 Mar 1994 18:55:07 -0500, stevenmz@teleport.com (Steven M. Ziuchkovski) said:
  2. > Errors-To: towfiq@sunsite.unc.edu
  3. > Errors-To: towfiq@sunsite.unc.edu
  4. > Originator: winsock@sunsite.unc.edu
  5.  
  6. > I'm just starting out programming with the WINSOCK.DLL. I've got a few files 
  7. > from rhino.microsoft.com, and did a LOT of reading, but the documentation does 
  8. > not seem to be that good (well, to me).
  9.  
  10. > Anyway, I'm trying to take a string (such as 'oak.oakland.edu') and determine 
  11. > it's numeric IP address (141.210.10.117) as a small excersize for myself to 
  12. > get started. I've gotten a small program that uses WSAStartup to determine the 
  13. > number of sockets available (szMaxSockets), etc. Then, I use GetHostByName to 
  14. > fill out a HostEnt record.
  15.  
  16. > The information in WINSOCK.DOC (rhino.microsoft.com:/Specification/winsock.DOC 
  17. > I think) is not to clear on the information of this record. I assume that the 
  18. > h_Addr_List field contains a list of IP addresses (which I guess is what I'm 
  19. > looking for). What format is this in? I cannot seem to be able to extract this 
  20. > information correctly. Either the numbers are totally wrong from what they 
  21. > should be, or produce a general protection fault.
  22.  
  23. > Could someone please offer an explanation or pointers? I'm programming using 
  24. > Borland Pascal v7.0.
  25.  
  26. > Thanks,
  27. > Steve
  28.  
  29. > ---
  30. >                                   ///      
  31. > Steven Ziuchkovski               (0 0)            stevenmz@teleport.com
  32. > ------------------------------ooO-(_)-Ooo------------------------------
  33.  
  34.  
  35. Steve,
  36.  
  37.   I don't have it in Pascal, but hope the following C code segment 
  38.   would help you.
  39.  
  40.   ----------
  41.  
  42.     struct hostent         *host_ent;
  43.     ...
  44.  
  45.     if ((host_ent = gethostbyname(buffer)) == NULL){
  46.         rc = WSAGetLastError();
  47.         print_error("winsock gethostbyname call failed -- %d", rc);
  48.         return FALSE;
  49.     }
  50.     /* suppose the address is 141.210.10.117, then ... 
  51.              *(*(host_ent->h_addr_list))      is 141
  52.              *(*(host_ent->h_addr_list) + 1)  is 210
  53.              *(*(host_ent->h_addr_list) + 2)  is 10
  54.              *(*(host_ent->h_addr_list) + 3)  is 117
  55.     */
  56.  
  57.   -----------
  58.  
  59.     dennis young
  60.  
  61.  
  62.